def get_primes_less_than(n):
    """获取所有小于给定数字的质数"""
    if not isinstance(n, int) or n <= 3:
        raise ValueError("输入必须是大于3的整数")
    
    primes = []
    for num in range(2, n):
        is_prime = True
        for i in range(2, int(num**0.5)+1):
            if num % i == 0:
                is_prime = False
                break
        if is_prime:
            primes.append(num)
    return primes

def get_primes_less_than2(n):
    """获取所有小于给定数字的质数（使用埃拉托斯特尼筛法）"""
    if not isinstance(n, int) or n <= 3:
        raise ValueError("输入必须是大于3的整数")
    
    sieve = [True] * n
    sieve[0] = sieve[1] = False  # 0和1不是质数
    
    for i in range(2, int(n**0.5)+1):
        if sieve[i]:
            # 将i的倍数标记为非质数
            sieve[i*i : n : i] = [False] * len(sieve[i*i : n : i])
    
    return [i for i, is_prime in enumerate(sieve) if is_prime]

# ... 原有main函数保持不变 ...

if __name__ == '__main__':
    try:
        input_num = int(input("请输入一个大于3的整数: "))
        result = get_primes_less_than2(input_num)
        print(f"小于 {input_num} 的质数有 {len(result)} 个：")
        print(', '.join(map(str, result)))
    except ValueError as e:
        print(f"输入错误: {str(e)}")
    except Exception as e:
        print(f"运行错误: {str(e)}")